package com.yc.meeting_attendance.net;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import java.net.ConnectException;

import rx.Subscriber;

/**
 * Created by Administrator on 2016-06-01.
 */
public abstract class AbsAPICallback<T> extends Subscriber<T> {
    private static final String TAG = "AbsAPICallback";
    Context mContext;
//    private SweetAlertDialog mLoadingDialog;


    public AbsAPICallback(Context context) {
        mContext = context;
//        showLoadingDialog();
    }

    @Override
    public void onCompleted() {
//        dismissLoadingDialog();
    }

    @Override
    public void onError(Throwable e) {
        Throwable throwable = e;
        //获取最根源的异常
        while (throwable.getCause() != null) {
            e = throwable;
            throwable = throwable.getCause();
        }

        if (e instanceof ConnectException) {
            Toast.makeText(mContext, "网络异常,请检查网络", Toast.LENGTH_LONG).show();
        }


//        dismissLoadingDialog();
    }

}
